﻿@using GdHotel.Data.Meta
@model IEnumerable<ImageModel>

@{
    ViewBag.Title = "Images";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

@section head {
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/images.js")" type="text/javascript"></script>
}

<h2>Картинки</h2>

@if (ViewBag.Message != null)
{
    <div class="message">@ViewBag.Message</div>
}

<fieldset>
    <legend>Загрузка картинок</legend>

    @using (Html.BeginForm("Load", "ManageImages", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        <div class="display-label">Выберите изображение</div>
        <div class="display-field">
            <input type="file" id="file" name="file" />
        </div>

        <fieldset>
            <legend>Обрезание</legend>        
            <div class="display-label">Ширина</div>
            <div class="display-field">
                <input type="text" id="cropToWidth" name="cropToWidth" /> пикс.
            </div>

            <div class="display-label">Высота</div>
            <div class="display-field">
                <input type="text" id="cropToHeight" name="cropToHeight" /> пикс.
            </div>
        </fieldset>
        <p>
            <input type="submit" value="Загрузить" />
        </p>
    }
</fieldset>

<fieldset>
    <legend>Картинки</legend>
    @if (!Model.Any())
    {
        <p>Не загружено ни одной картинки</p>
    }
    else
    {
        <ul class="image-thumbnails">
        @foreach (var image in Model)
        {
            <li>
            <div class="image-thumbnail">
                <img src="@image.Url" alt="@image.FileName" />
            </div>
            <div class="image-data">
                <ul>
                    <li>@image.FileName</li>
                    <li>@image.Width x @image.Height</li>
                    <li><input class="url-input" type="text" style="width : 144px; font-size:12px;" value="@(image.Url.Replace(",", "%2c").Replace(" ", "%20"))"/></li>
                </ul>
            </div>
            </li>
        }
        </ul>
    }
</fieldset>
